
package com.welsy.iter.business
{
	import com.adobe.cairngorm.business.ServiceLocator;
	import com.welsy.iter.vo.IterVO;
	
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.soap.mxml.WebService;		

	/**
	  * @author Welsy.org
	  * @version	$Revision: 1.1 $
	  */
	public class AddIterDelegate
	{
		/**
		  * Delegate initialization for course component retrieval
		  * @param responder The event handler fo the server response
		  */
		public function AddIterDelegate( responder : IResponder )
		{		
			this.service = ServiceLocator.getInstance().getWebService("iterServices") as WebService;
			
			this.responder = responder;
		}
		
		public function AddIter( newIter : IterVO ) : void
		{	
			var o:AbstractOperation = service.getOperation("AddIter");
			o.arguments.AddIterRequest.IterId = newIter.id;
			o.arguments.AddIterRequest.ParentIterId = newIter.parentIterId;
			o.arguments.AddIterRequest.Title = newIter.title;
			o.arguments.AddIterRequest.TitleUser = newIter.titleUser;
			o.arguments.AddIterRequest.AuthorId = newIter.authorId;
			o.arguments.AddIterRequest.CreditsNumber = newIter.creditsNumber;
			o.arguments.AddIterRequest.Credits = newIter.credits;
			o.arguments.AddIterRequest.State = newIter.state;
			o.arguments.AddIterRequest.Notes = newIter.notes;
			
			var token:AsyncToken = service.AddIter();
			// notify this command when the service call completes
			token.addResponder( responder );
		}	
		
		private var responder : IResponder;
		private var service : Object;
	}

}